package com.situ.service.impl;

import java.util.List;

import com.situ.dao.CommodityDao;
import com.situ.entily.Commodity;
import com.situ.service.CommodityService;

public class CommodityServiceImpl implements CommodityService {

	CommodityDao dao=new CommodityDao();
	
	

	@Override
	public List<Commodity> all(int page, int limit, String keyword) {
		return dao.all((page - 1) * limit, limit, keyword);
	}

	@Override
	public Long count(String keyword) {
		return dao.count(keyword);
	}

	@Override
	public Commodity selectById(Integer id) {
		return dao.selectById(id);
	}

	@Override
	public void save(Commodity c) {
		if (c.getCommId() == null) {
			dao.insert(c);
		} else {
			dao.update(c);
		}
		
	}

	@Override
	public void delete(Integer id) {
		dao.delete(id);		
	}

	@Override
	public List<Commodity> selall() {
		return dao.selall();
	}

}
